<template>
  <div class='container'>
    <el-row>
      <el-col :span="6"><span>【题型】:{{listView.questionType}}</span></el-col>
      <el-col :span="6"><span>【编号】:{{listView.id}}</span></el-col>
      <el-col :span="6"><span>【难度】:{{listView.difficulty}}</span></el-col>
      <el-col :span="6"><span>【标签】:{{listView.tags}}</span></el-col>
      <el-col :span="6"><span>【学科】:{{listView.subjectName}}</span></el-col>
      <el-col :span="6"><span>【目录】:{{listView.directoryName}}</span></el-col>
      <el-col :span="6"><span>【方向】:{{listView.direction}}</span></el-col>
    </el-row>
    <span class="line"></span>
    <div>
      <span>【题干】:</span>
      <p class="question">{{listView.question}}</p>
    </div>
    <!-- 单选多选位置 -->
    <div>
      <span>{{listView.questionType}}题选项：(以下选项中的答案为正确答案)</span>
      <br>
      <template v-if="listView.questionType=='单选'">
        <el-radio-group :value="list">
          <el-radio v-for="item in options" :label="item.isRight" :key="item.id">{{item.title}}</el-radio>
        </el-radio-group>
      </template>
      <template  v-if="listView.questionType=='多选'">
        <el-checkbox-group :value="lists">
          <el-checkbox v-for="item in options" :label="item.isRight" :key="item.id">{{item.title}}</el-checkbox>
        </el-checkbox-group>
      </template>
    </div>
    <span class="line"></span>
    <!-- 视频预览位置 -->
    <div>
      <span>参考答案：</span>
      <el-button type="danger" @click="showVideo=!showVideo">视频答案预览</el-button>
      <video ref="video" controls="controls" :src="listView.videoURL" v-show="showVideo" autoplay>
      </video>
    </div>
    <span class="line"></span>
    <!-- 答案解析与备注 -->
    <div>
      <span>【答案解析】：{{listView.answer}}</span>
    </div>
    <span class="line"></span>
    <div>
      <span>【题目备注】：{{listView.remarks}}</span>
    </div>
    <!-- 关闭 -->
    <el-row>
      <el-col :offset="12">
        <el-button class="close" type="primary" @click="btnClose">关闭</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'questView',
  props: {
    // 当前题目详情
    listView: {
      required: true
    },
    // 数据转换完成的选项详情
    options: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      showVideo: false,
      type: [1],
      radio: 1
    }
  },
  computed: {
    // 多选框
    lists () {
      return this.type
    },
    // 单选框
    list () {
      return this.radio
    }
  },
  methods: {
    btnClose () {
      this.$emit('close')
      this.showVideo = false
    }
  }
}
</script>

<style lang="scss" scoped>
.el-col {
  margin-bottom: 15px;
}
.line {
  display: block;
  margin: 10px 0;
  border: 1px solid  #d3dce6;
}
.question {
  color: blue;
}
.close {
  text-align: center;
  margin-top: 30px;
  transform: translateX(-50%);
}
.el-radio,.el-checkbox {
  display: block;
  margin-top: 15px;
}
video {
  display: block;
  margin-top: 30px;
  width: 350px;
}
</style>
